package com.hzl.controller;

import com.hzl.entity.vo.CategoryAllVo;
import com.hzl.entity.vo.api.R;
import com.hzl.service.CategoryService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.List;

/**
 * @author huangzelnag
 * @create 2022-05-04
 */
@RestController
@RequestMapping("/category")
public class CategoryController {
    @Autowired
    CategoryService categoryService;

    /**
     * 获取所有
     * @return
     */
    @GetMapping("/list")
    public R getCategoryAll(){

        List<CategoryAllVo> categoryAll = categoryService.getCategoryAll();

        if(categoryAll==null){
            return R.Code(0).Msg("列表不存在");
        }
        return R.Code(1).data(categoryAll);
    }

}
